#include "terminal.c"

static void *
print_help(void *args[])
{
    printf("This is test for terminal.\n");
    return NULL;
}

static void *
say_goodbye(void *args[])
{
    printf("Have a nice day!!!\n");
    exit(EXIT_SUCCESS);
}

static void *pass_args(void *args[])
{
    printf("pass_args\n");
    for (int i = 1; i < 4; i++)
    {
        if (args[i])
        {
            printf("%s ", (char*)args[i]);
        }
    }
    printf("\n");
    
    return NULL;
}

static void *pass_args_with_1st(void *args[])
{
    printf("pass_args\n");
    printf("%d\n", *((int*)args[0]));
    for (int i = 1; i < 4; i++)
    {
        if (args[i])
        {
            printf("%s ", (char*)args[i]);
        }
    }
    printf("\n");
    
    return NULL;
}

int main()
{
    struct terminal tml;
    int sock = 1;
    add_option(&tml, "help", print_help, NULL);
    add_option(&tml, "quit", say_goodbye, NULL);
    add_option(&tml, "pass", pass_args, NULL);
    add_option(&tml, "pass1", pass_args_with_1st, &sock);
    run_terminal(&tml);
    return 0;
}